﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace WebClasses.Extensions
{
    public static class ListControlExtensions
    {
        public static void BindDataByEnumType(this ListControl list, Type enumType)
        {
            list.Items.Add(new ListItem("请选择", "-1"));
            string[] names = Enum.GetNames(enumType);
            foreach (string name in names)
            {
                int value = (int)(Enum.Parse(enumType, name));
                list.Items.Add(new ListItem(name, value.ToString()));
            }
        }
    }
}
